package controller

import (
	"gitee.com/zenpk/backend-demo/internal/middleware"
	"gitee.com/zenpk/backend-demo/internal/service"
	"github.com/gin-gonic/gin"
)

func InitRouter(router *gin.Engine) {
	router.Static("/static", "./assets/public") // 静态资源路径
	router.Use(middleware.CORSFilter())         // CORS

	// 不做任何登录验证的 URL
	router.GET("/importData/stutable", handler.studentInfo.GetAll)
	router.GET("/importData/stuquery", handler.studentInfo.GetAllByParams)
	router.GET("/importData/getastu", handler.studentInfo.GetById)
	router.POST("/importData/addstu", handler.studentInfo.Add)
	router.PUT("/importData/editstu", handler.studentInfo.Edit)
	router.DELETE("/importData/delstu", handler.studentInfo.Delete)
	router.POST("/user/login", handler.userCredential.Login)
	router.POST("/user/register", handler.userCredential.Register)
	router.GET("/user/logout", handler.userCredential.Logout)
	router.GET("/user/state", handler.userCredential.LoginState)
	//获得学生基本信息接口
	router.GET("/consulting/myrecord/getastu", handler.consultStudentInfo.GetByStuNum)
	router.GET("/consulting/myrecord/gettestrecord", handler.testRecord.GetTestRecord)               //获取测评记录接口
	router.GET("/consulting/myrecord/getassessmentrecord", handler.evaluateRecord.GetEvaluateRecord) //获取评估记录接口
	router.GET("/consulting/myrecord/getprocess", handler.consultSituation.GetConsultSituation)      //获取咨询情况接口
	router.GET("/consulting/myrecord/getreserverecord", handler.reserveRecord.GetReserveRecord)      //获取预约记录信息接口
	router.GET("/consulting/myrecord/gradechange", handler.gradeAlter.GetGradeAlter)                 //获取等级异动信息接口
	//添加下一次记录接口
	router.POST("/consulting/myrecord/addnext", handler.consultSituation.AddNext)
	//获取咨询学生咨询记录表单数据接口
	router.GET("/consulting/myrecord/getrecords", handler.consultSituation.GetStudentConsultRecord)
	//删除单个学生咨询记录表单数据接口
	router.DELETE("/consulting/myrecord/delrecord", handler.consultSituation.DeleteStudentConsultRecord)
	//编辑单个学生咨询记录表单
	router.PUT("/consulting/myrecord/editrecord", handler.consultSituation.EditStudentConsultRecord)
	//添加单个学生咨询记录表单
	router.POST("/consulting/myrecord/addrecord", handler.consultSituation.AddStudentConsultRecord)
	//按条件查询咨询学生咨询记录表单
	router.GET("consulting/myrecord/queryrecords", handler.consultSituation.GetStudentConsultRecordByPara)
	//重新开启单个咨询记录接口
	router.PUT("consulting/myrecord/reopen", handler.consultSituation.ReopenConsultSituation)
	//结案单个咨询记录接口
	router.PUT("/consulting/myrecord/giveend", handler.consultSituation.GiveEnd)
	// 不需要登录，但可以从 token 中获取用户信息的 URL
	routerNoAuth := router.Group("/")
	routerNoAuth.Use(middleware.CheckAuthInfo())
	{
		routerNoAuth.GET("/index", service.HelloDemo)
	}

	// 需要登录的 URL
	routerAuth := router.Group("/")
	routerAuth.Use(middleware.RequireLogin())
	{
		routerAuth.GET("/user-page", service.UserDemo)
		routerAuth.GET("/admin-page", service.AdminDemo)
		routerAuth.GET("/all-users", handler.userInfo.GetAllUserInfos)
		routerAuth.GET("/my-info", handler.userInfo.GetUserInfo)
	}
}
